package com.springboot.news.validation;

import com.springboot.news.anno.Status;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class StatusValidetion implements ConstraintValidator<Status, String> {
//    ConstraintValidator<State, String> 给state 添加校验 string指定类型
    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
//        System.out.println(1111);
//        System.out.println(value);
//        value是校验的数据
        if (value == null) {
            return false;
        }
        if (value.equals("发布") || value.equals("草稿")) {
            return true;
        }
        return false;
    }
}
